<template>
  <div>
    <el-dialog title="选择进驻公司" :visible.sync="dialogVisible" width="80%">
      <data-list :pageInfo="pager" placeholder="请输入公司名称" :listData="tableData" searchName="customerName" noPadding :menuList="[]" openSelection>
        <el-table :data="tableData" align="center" @selection-change="$event => (multipleSelection = $event)">
          <el-table-column width="60px" type="selection" align="center"></el-table-column>
          <el-table-column label="公司名称" prop="customerName" align="center"></el-table-column>
          <!--                    <el-table-column label="客户id" prop="customerId" align="center"></el-table-column>-->
          <!--                    <el-table-column label="进驻园区" prop="contractName"  align="center"></el-table-column>-->
          <el-table-column label="合同开始日期" prop="startDate" align="center"></el-table-column>
          <el-table-column label="合同结束日期" prop="endDate" align="center"></el-table-column>
          <el-table-column label="月租金" prop="rentAmount" align="center"></el-table-column>
        </el-table>
        <template>
          <el-button v-throttle="[selectionChange]">确定</el-button>
        </template>
      </data-list>
    </el-dialog>
  </div>
</template>

<script>
import { getCompList } from "../api/assessindustrial";


export default {
  name: "CompList",
  provide () {
    return {
      initList: this.getListData,
    };
  },
  data () {
    return {
      dialogVisible: false,
      tableData: [],
      multipleSelection: [],
      filterList: [
        {
          label: '公司名称',
          type: 'input',
          name: 'customerName'
        },
      ],
      // 分页
      pager: {
        total: 0, // 总页数
        current: 1, // 当前页数
        size: 10 // 每页显示多少条
      },
      params: {
        current: 1,
        size: 10,
        customerName: ''
      },
    }
  },
  methods: {
    //勾选改变
    selectionChange () {
      if (this.multipleSelection.length > 1) {
        this.$message.error("只能勾选一个，请重新选择")
      } else if (this.multipleSelection.length == 0) {
        this.$message.error("您没有勾选，请再次确认")
      } else {
        this.$message.success("勾选成功")
        this.$emit("giveList", this.multipleSelection)
        this.dialogVisible = false
      }
    },
    show () {
      this.dialogVisible = true
      this.getListData();
    },
    getListData (params = {}) {
      let req = { ...this.params, ...params }
      getCompList(req).then(resp => {
        let { size, current, total, records } = resp.data.data
        this.tableData = records
        this.params = req
        this.pager = { size, current, total }
      })

    },
    handleClose (done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => { });
    },
  },
}
</script>

<style scoped>
</style>
